<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <title>市场中心</title>
    <link rel="stylesheet" href="../css/base.css"/>
    <link rel="stylesheet" href="../css/header.css"/>
    <link rel="stylesheet" href="../css/my_market.css"/>
    <style>
        .list ul{
            width: 100%;
        }
        .list ul li .top{
            width: 100%;
            height: 0.96rem;
            line-height: 0.96rem;
            padding: 0 0.3rem;
            padding-bottom: 0.2rem;
            border-bottom: 1px solid #eeeeee;
        }
        .list .top .left{
            font-size:0.28rem;
            color:#6e6e6e;
        }
        .list .top .right{
            color:#ff7e58;
        }
        .list .top .left i{
            width: 0.6rem;
            height: 0.96rem;
            display: inline-block;
            background: url("../img/right_03.png") no-repeat center;
            -webkit-background-size: 90%;
            background-size: 90%;
            vertical-align: middle;
        }
        .list ul li .center{
            padding: 0 0.3rem;
            position: relative;
            background-color: #f4f4f4;
            width: 100%;
            height: 1.5rem;
            margin-top: 0.2rem;
        }
        .list ul li .center img{
            position: absolute;
            left: 3%;
            margin-top: 0.1rem;
            width: 1.3rem;
            min-height: 1.3rem;
            vertical-align: middle;
        }
        .list ul li .center span{
            position: absolute;
            left: 1.7rem;
            width: 55%;
            margin-top: 0.2rem;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            word-break: break-all;
        }
        .list ul li .center .right{
            position: absolute;
            right: 3%;
            margin-top: 0.2rem;
        }
        .list ul li .center .right i{
            display: block;
            color: #ff5000;
            font-size: 0.3rem;
        }
        .list ul li .center .right em{
            text-decoration: line-through;
        }
        .list ul li .total{
            height: 1rem;
            line-height: 1rem;
            padding-right: 0.3rem;
            font-size: 0.24rem;
            position: relative;
            padding-bottom: 0.2rem;
            border-bottom: 1px solid #eeeeee;
        }
        .list ul li .total span{
            position: absolute;
            right: 3%;
        }
        .list ul li .apply{
            position: relative;
            height: 0.8rem;
            line-height: 0.8rem;
            margin: 0.2rem 0;
        }
        .list ul li .apply button{
            position: absolute;
            width: 25%;
            height: 100%;
            font-size: 0.3rem;
            border-radius: 10px;
            background-color: #fff;
        }
        .list ul li .apply .see{
            right: 30%;
            border: 1px solid #b7b7b7;
        }
        .list ul li .apply .receiving,.list ul li .apply .remind{
            right: 3%;
            border: 1px solid #ff7e58;
            color:#ff7e58;
        }
        .list ul li .see_comment{
            right: 3%;
            border: 1px solid #ff7e58;
            color:#ff7e58;
        }

    </style>
</head>
<body>
<div class="layer">
    <header>
        <i onclick="location.href='./local_market.html'"></i>
        <h3>市场中心</h3>
    </header>
    <div class="nav clearfix">
        <ul class="clearfix">
            <li>
                <a href="./my_market.html" >出售中</a>
            </li>
            <li>
                <a href="./my_market_published.html" >已发布</a>
            </li>
            <li>
                <a href="./my_market_order.html"  class="active">全部订单</a>
            </li>
            <li>
                <a href="./my_market_save.html">收藏</a>
            </li>
            <li>
                <a href="./my_market_pay.html">佣金</a>
            </li>
        </ul>
    </div>
    <div class="list">
        <!--<ul class="clearfix">
          <li>
              <div class="top clearfix" onclick="location.href='local_market_shop.html'">
                  <div class="left f_left">
                      米朵曦曦童装店
                      <i></i>
                  </div>
                  <div class="right f_right">
                      卖家已发货
                  </div>
              </div>
              <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html'">
                  <img src="../img/focus-img1.png" alt=""/>
                  <span>女童洋气套装2018新款春秋装儿童时 尚运动金丝绒两件套小孩小孩卫衣装小孩卫衣装小孩卫衣装</span>
                  <div class="right ">
                      <i>￥ 59.9</i>
                      <em>￥190</em>
                  </div>
              </div>
             <div class="total clearfix">
               <span>  共一件商品&nbsp;&nbsp;合计：￥29.50</span>
             </div>
              <div class="apply">
                  <button class="see" onclick="location.href='./my_market_see_order.html'" >查看物流</button>
                  <button class="receiving">确认收货</button>
              </div>
          </li>
          <li>
              <div class="top clearfix">
                  <div class="left f_left">
                      米朵曦曦童装店
                      <i></i>
                  </div>
                  <div class="right f_right">
                      卖家已发货
                  </div>
              </div>
              <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html'">
                  <img src="../img/focus-img1.png" alt=""/>
                  <span>女童洋气套装2018新款春秋装儿童时 尚运动金丝绒两件套小孩小孩卫衣装小孩卫衣装小孩卫衣装</span>
                  <div class="right ">
                      <i>￥ 59.9</i>
                      <em>￥190</em>
                  </div>
              </div>
             <div class="total clearfix">
               <span>  共一件商品&nbsp;&nbsp;合计：￥29.50</span>
             </div>
              <div class="apply">
                  <button class="see_comment" onclick="location.href='./publish_comment.html'">评价</button>
              </div>
          </li>
          <li>
              <div class="top clearfix">
                  <div class="left f_left">
                      米朵曦曦童装店
                      <i></i>
                  </div>
                  <div class="right f_right">
                      卖家已发货
                  </div>
              </div>
              <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html'">
                  <img src="../img/focus-img1.png" alt=""/>
                  <span>女童洋气套装2018新款春秋装儿童时 尚运动金丝绒两件套小孩小孩卫衣装小孩卫衣装小孩卫衣装</span>
                  <div class="right ">
                      <i>￥ 59.9</i>
                      <em>￥190</em>
                  </div>
              </div>
             <div class="total clearfix">
               <span>  共一件商品&nbsp;&nbsp;合计：￥29.50</span>
             </div>
              <div class="apply">
                  <button class="see" onclick="location.href='./my_market_see_order.html'">查看物流</button>
                  <button class="receiving">确认收货</button>
              </div>
          </li>
        </ul>-->
    </div>
</div>
</body>
<script src="../js/x_rem.js"></script>
<script src="../js/base.js"></script>
<script src="../js/jquery.js"></script>
<script src="../js/template-web.js"></script>
<script id="order" type="text/html">
    <ul class="clearfix">
        {{if list.length ==0}}
        <li class="no_order">对不起，你暂时没有任何订单!</li>
        {{else}}
        {{each list as value i}}
        {{if value.goods.category==0}}
        {{if value.goods.status=0}}
        <li>
            <div class="top clearfix" onclick="location.href='local_market_shop.html'">
                <div class="left f_left">
                    {{value.goods.goodsName}}
                </div>
                <div class="right f_right">
                    等待发货
                </div>
            </div>
            <div class="center clearfix">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;跑腿费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="remind" >提醒发货</button>
            </div>
        </li>
        {{else if value.status==1}}
        <li>
            <div class="top clearfix">
                <div class="left f_left">
                    {{value.goods.goodsName}} 米朵曦曦童装店
                    <i></i>
                </div>
                <div class="right f_right">
                    卖家已发货
                </div>
            </div>
            <div class="center clearfix">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;跑腿费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="receiving" data-order="{{value.goodsOrderId}}">确认收货</button>
            </div>
        </li>
            {{else if value.status==2}}
        <li>
            <div class="top clearfix">
                <div class="left f_left">
                    {{value.goods.goodsName}} 米朵曦曦童装店
                    <i></i>
                </div>
                <div class="right f_right">
                    卖家已发货
                </div>
            </div>
            <div class="center clearfix">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;跑腿费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="see_comment" onclick="location.href='./publish_comment.html?goodsOrderId={{value.goodsOrderId}}'">评价</button>
            </div>
        </li>

        {{/if}}

        {{else if value.goods.category==1}}
        {{if value.status==0}}
        <li>
            <div class="top clearfix" onclick="location.href='local_market_shop.html'">
                <div class="left f_left">
                    {{value.goods.goodsName}} 米朵曦曦童装店
                    <i></i>
                </div>
                <div class="right f_right">
                    等待发货
                </div>
            </div>
            <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html?goodsOrderId={{value.goodsOrderId}}'">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;邮费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="remind" >提醒发货</button>
            </div>
        </li>

        {{else if value.status==1}}
        <li>
            <div class="top clearfix">
                <div class="left f_left">
                    {{value.goods.goodsName}} 米朵曦曦童装店
                    <i></i>
                </div>
                <div class="right f_right">
                    卖家已发货
                </div>
            </div>
            <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html?goodsOrderId={{value.goodsOrderId}}'">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;邮费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="see" onclick="location.href='./my_market_see_order.html?goodsOrderId={{value.goodsOrderId}}'">查看物流</button>
                <button class="receiving" data-order="{{value.goodsOrderId}}">确认收货</button>
            </div>
        </li>
        {{else if value.status==2}}
        <li>
            <div class="top clearfix">
                <div class="left f_left">
                    米朵曦曦童装店
                    <i></i>
                </div>
                <div class="right f_right">
                    卖家已发货
                </div>
            </div>
            <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html?goodsOrderId={{value.goodsOrderId}}'">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;邮费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="see_comment" onclick="location.href='./publish_comment.html?goodsOrderId={{value.goodsOrderId}}'">评价</button>
            </div>
        </li>
        {{else}}
        <li>
            <div class="top clearfix">
                <div class="left f_left">
                    米朵曦曦童装店
                    <i></i>
                </div>
                <div class="right f_right">
                    卖家已发货
                </div>
            </div>
            <div class="center clearfix" onclick="location.href='./my_market_see_order_detail.html?goodsOrderId={{value.goodsOrderId}}'">
                <img src="{{value.goods.images[0].path}}" alt=""/>
                <span>{{value.goods.introduction}}</span>
                <div class="right ">
                    <i>￥{{value.goods.smallPrice}}</i>
                    <em>￥{{value.goods.price}}</em>
                </div>
            </div>
            <div class="total clearfix">
                <span>  共{{value.number}}件商品&nbsp;&nbsp;邮费：￥{{value.goods.expressFee==null?0:value.goods.expressFee}} 合计：￥{{value.price}}</span>
            </div>
            <div class="apply">
                <button class="see_comment" onclick="location.href='./publish_comment.html?goodsOrderId={{value.goodsOrderId}}'">追加评价</button>
            </div>
        </li>
        {{/if}}
        {{/if}}
        {{/each}}
        {{/if}}
    </ul>
</script>
<script >
    $(function(){
        // /goods/checkGoods 确认收货

        render();

        function render(){
            $.ajax({
                //处理session每次不唯一问题
                xhrFields: {
                    withCredentials: true
                },
                async:false,
                type: "post",
                url: baseUrl+"/goods/getGoodsOrder",
                data:{},
                dataType: 'json',
                success:function(data) {
                    console.log(data);
                    if(data.code=="success"||data.state==true){

                    $(".list").html(template("order",data));

                    }else{
                        alert("网络错误，请稍后重试");
                        location.href='./login.html'
                    }

                }

            })
        }
        $(".remind").click(function(){
            $(this).text("已提醒");
        })
        //确认收货
        function checkGoods(goodsOrderId){
            $.ajax({
                //处理session每次不唯一问题
                xhrFields: {
                    withCredentials: true
                },
                async:false,
                type: "post",
                url: baseUrl+"/goods/checkGoods",
                data:{
                    goodsOrderId:goodsOrderId
                },
                dataType: 'json',
                success:function(data) {
                    console.log(data);
                    if(data.code=="success"){
                        render();
                    }else{
                        alert("网络错误，请稍后重试");
                    }
                }

            })
        }
        $(".receiving").click(function () {
            var id=$(this).data("order");
            checkGoods(id);
        })
    })
</script>
</html>